/* 
 * File:   ImageConverter.cpp
 * Author: Guilherme Monteiro
 * 
 */

#include "../headers/ImageFormatConverter.h"

/**
 * Constructor of ImageConverter class.
 * 
 * @param 
 */
ImageFormatConverter::ImageFormatConverter(TessMetaInfo* meta) {
    this->metainfo = meta;
}

ImageFormatConverter::ImageFormatConverter(const ImageFormatConverter& orig) {
}

ImageFormatConverter::~ImageFormatConverter() {
}

/**
 * Convert the high table image to one
 * tiff image and save it in the tiff image
 * path indicated to metainfo.
 */
void ImageFormatConverter::convertToTiffFormat() throw (NullImageException) {
    try {
        InitializeMagick(metainfo->getTIFFImagePath().c_str());

        // Read GIF file from disk 
        Image image( metainfo->getHighResolutionTablePath().c_str());

        // Write to BLOB in JPEG format 
        Blob blob; 
        image.magick( "TIFF" ); // Set TIFF output format 
        image.write( metainfo->getTIFFImagePath().c_str() );
    }
    catch(NullImageException nie) {
        throw nie;
    }
}

